﻿component extends="org.corfield.framework" {
	this.directory = getDirectoryFromPath( getCurrentTemplatePath() );

	// Configure application mappgins. In this case, we'll be using the uploads and chunks
	// mapping with the expandPath() function later on when saving files.
	this.mappings[ "/uploads" ] = ( this.directory & "uploads/" );
	this.mappings[ "/chunks" ] = ( this.directory & "chunks/" );

    this.name = "b2c";
    this.sessionManagement = true;
    this.sessionTimeout = createTimeSpan(0,1,0,0);
    this.dataSource = this.name;
    this.ormEnabled = true;

    this.ormsettings = {
        cfclocation="./model/beans",
        dbcreate="update",       // update database tables only
        dialect="MySQL",         // assume MySql, other dialects available http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html
        eventhandling="true",
        eventhandler="root.model.beans.eventhandler",
        logsql="true"
    };


    this.mappings["/root"] = getDirectoryFromPath(getCurrentTemplatePath());

    variables.framework = {
        reloadApplicationOnEveryRequest = "true",
        trace = "false"
    };

    public function setupSession() {
		//	控制用户session，获取用户登陆信息内容
        controller('security.session');
    }


    public function setupApplication() {

    	Application.DataMgr = CreateObject("component","DataMgr.DataMgr_MYSQL").init(this.dataSource);

        var bf = new framework.ioc("./model/services"); // ColdFusion ORM handles Beans
        setBeanFactory(bf);

		//设置全局变量
        request.rows = 10;
		request.baiduAk= '1FRohQ2W2TH9XGvEHmuckB6G';

    }

    public function setupRequest() {
        if(structKeyExists(url, "init")) { // use index.cfm?init to reload ORM
            setupApplication();
            ormReload();
            location(url="index.cfm",addToken=false);
        }
		// 权限控制判断
        controller("security.authorize");
    }

}
